#include <bits/stdc++.h>
using namespace std;

int n, mn = INT_MAX;
int arr[105][105];

void func() {
    int tmp[105][105];
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            tmp[i][j] = arr[n + 1 - j][i];
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            arr[i][j] = tmp[i][j];
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j) {
            cin >> arr[i][j];
            mn = min(mn, arr[i][j]);
        }
    while (arr[1][1] != mn)
        func();

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j)
            cout << arr[i][j] << ' ';
        cout << endl;
    }
    return 0;
}